<template>
<div class="love">
    <h2 class="nxh">猜你喜欢</h2>
    <div class="like">
        <div :class="{active: currentIndex0 == index }" @click="handleClick(index),sortClick(index)" class="Zh" v-for="(item,index) in list" :key="index">{{item}}</div>
    </div>
    <div class="Lable">
        <div class="box">年货节热卖</div>
        <div class="box">津贴联盟</div>
        <div class="box">满减优惠</div>
        <div class="box">品质联盟</div>
    </div>
    <div class="store">
        <div class="store_1" v-for="(item,index) in storeArr" :key="index">
            <img :src="item.img" alt="">
            <span class="title">{{item.title}}</span>
            <br>
            <span class="score">{{item.score}}</span>
            <span class="num">月售{{item.num}}</span>
            <br>
            <span class="amount">起送￥{{item.amount}}</span>
            <span class="remote">远距离配送￥{{item.remote}}</span>
            <span class="min">{{item.min}}分钟</span>
            <span class="km">{{item.km}}km</span>
            <br>
            <span class="yzcf">{{item.yzcf}}</span>
            <span class="pm">{{item.pm}}</span>
            <br>
            <ul>
                <li class="mj" v-for="(item,index) in item.mj" :key="index">{{item}}</li>
            </ul>
        </div>
    </div>
</div>
</template>

<script>
export default {
    data(){
        return {
            currentIndex0: 0,
            list:[
            '综合排序', '距离最近', '销量最高', '筛选'
            ],
            storeArr: [
                { img: "https://ts1.cn.mm.bing.net/th/id/R-C.af81ac6eee795b8be73ea3108c4c9db4?rik=%2flw9QunpULFmKg&riu=http%3a%2f%2fimg.crcz.com%2fallimg%2f202002%2f11%2f1581388393842131.jpg&ehk=D%2fd0wiF3zd1pSooP7DOKWPOUzJyn9lS%2bZso8ctu3Zao%3d&risl=&pid=ImgRaw&r=0&sres=1&sresct=1", title: '金百万烤鸭(苏家坨店)', score: '4.3', num: '1632', amount: '20', remote: '3', min: '47', km: '3.9', yzcf: '“扬州炒饭棒棒哒”', pm: '海淀区北京菜畅销第2名', mj: ['35减12', '70减35', '100减45', '150减80'] },
                { img: "https://ts1.cn.mm.bing.net/th/id/R-C.854807371f11ff8fb4eee139e51a2668?rik=yWfiO4sICNKjpA&riu=http%3a%2f%2fgx8899.com%2fuploads%2fallimg%2f2017121808%2fl3jldsoxxrd.jpg&ehk=KDbyckeNoA0K2R6%2b9YminBvQjhanogjNM00WY99Aidw%3d&risl=&pid=ImgRaw&r=0&sres=1&sresct=1", title: '稻香金源饺子馆', score: '4.4', num: '230', amount: '20', remote: '3.5', min: '44', km: '2.5', mj: ['40减5', '69减8', '100减10', '支持自取'] }
            ]
        }
    },
    methods:{
        handleClick(index) {
            this.currentIndex0 = index;
        },
        sortClick(index){
            if(index == 0){
                this.storeArr.sort((a,b)=>{
                    return b.num - a.num;
                })
            }else if(index == 1){
                this.storeArr.sort((a,b)=>{
                    return a.km - b.km;
                })
            }else if(index == 2){
                this.storeArr.sort((a,b)=>{
                    return b.num - a.num;
                })
            }
        }
    }
}
</script>

<style lang="scss" scoped>
.love .nxh{
    margin-left: 3%;
    margin-bottom: 2%;
}
.love .like {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: space-around;
    text-align: center;
}
.love .like div.active {
    font-weight: bolder;
    color: red;
}
.love .Lable {
    width: 94%;
    margin: auto;
    margin-top: 10px;
    display: flex;
    justify-content: space-around;
}

.love .Lable .box {
    background-color: #f5f5f5;
    padding: 5px 15px;
    font-size: 12px;
    border-radius: 5px;
}
.love .store {
    width: 94%;
    margin: auto;
    margin-top: 20px;
}
.love .store_1  {
    margin-top: 2%;
    height: 130px;
}
.love .store_1 img {
    width: 100px;
    height: 100px;
    float: left;
}

.love .store_1 .title {
    display: inline-block;
    margin-left: 10px;
    margin-bottom: 5px;
    font-weight: bolder;
}

.love .store_1 .score {
    color: orange;
    font-size: 10px;
    margin-left: 10px;
}

.love .store_1 .num {
    color: #999;
    font-size: 10px;
    margin-left: 10px;
}

.love .store_1 .amount {
    color: #999;
    font-size: 10px;
    margin-left: 10px;
}

.love .store_1 .remote {
    color: #999;
    font-size: 10px;
}

.love .store_1 .min {
    color: #999;
    font-size: 10px;
    margin-left: 15px;
}

.love .store_1 .km {
    color: #999;
    font-size: 10px;
    margin-left: 10px;
}
.love .store_1 .yzcf{
    margin-left: 10px;
    background-color: rgb(255, 238, 224);
    color: orangered;
    font-size: 10px;
}
.love .store_1 .pm {
    background-color: rgb(255, 238, 224);
    color: orangered;
    font-size: 10px;
}
ul{
    list-style: none;
    margin-top: 10px;
    margin-left: 100px;
}
li{
    font-size: 12px;
    float: left;
    text-align: center;
    width: 50px;
    height: 20px;
    border: 1px solid orangered;
    color: orangered;
    margin-left: 10px;
    line-height: 20px;
    border-radius: 4px;
}
</style>